const mysql = require('mysql2/promise');

(async () => {
  const pool = mysql.createPool({host:'localhost',user:'root',password:'123456',database:'chatime'});
  try {
    console.log('--- 所有用户信息 ---');
    const [users] = await pool.execute('SELECT id, name, phone FROM users');
    users.forEach(u => console.log(`用户ID: ${u.id}, 昵称: ${u.name}, 手机: ${u.phone}`));

    console.log('\n--- 所有pending好友申请 ---');
    const [requests] = await pool.execute('SELECT * FROM friend_requests WHERE status="pending"');
    if (requests.length === 0) {
      console.log('没有任何pending状态的好友申请');
    } else {
      requests.forEach(r => {
        console.log(`申请ID: ${r.id}, 发送者: ${r.sender_id}, 接收者: ${r.receiver_id}, 消息: ${r.message}, 创建时间: ${r.create_time}`);
      });
    }
  } catch (e) {
    console.error('检测失败:', e);
  } finally {
    await pool.end();
  }
})(); 